package com.lantosec.hmrp.modules.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.lantosec.hmrp.core.mvc.BaseEntity;
import com.lantosec.hmrp.modules.system.vo.SysUserVO;
import lombok.Data;

/**
 * <p>
 * 用户表
 * </p>
 *
 * @author AutoCode
 * @since 2020-02-07
 */
@Data
public class SysUser extends BaseEntity<SysUserVO> {

    private static final long serialVersionUID = 1L;
    /**
     * 用户ID
     */
    @TableId(value = "user_id", type = IdType.ASSIGN_UUID)
    private String userId;
    /**
     * 用户名
     */
    private String username;
    /**
     * 密码
     */
    private String password;
    /**
     * 姓名
     */
    private String name;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 图像
     */
    private String picture;
    /**
     * 状态
     */
    private Integer state;
    /**
     * 删除状态
     */
    private Integer flag;

    /**
     * 部门名称
     */
    @TableField(exist = false)
    private String deptName;

    @TableField(exist = false)
    private String deptId;

    /**
     * 岗位名称
     */
    @TableField(exist = false)
    private String positionName;

    @TableField(exist = false)
    private String positionId;

    @TableField(exist = false)
    private String mainDept;

    @TableField(exist = false)
    private String roleName;

    @TableField(exist = false)
    private String permission;

    public SysUser() {
    }

    public SysUser(SysUserVO vo) {
        this.userId = vo.getUserId();
        this.username = vo.getUsername();
        this.password = vo.getPassword();
        this.name = vo.getName();
        this.phone = vo.getPhone();
        this.picture = vo.getPicture();
        this.state = vo.getState();
        this.flag = vo.getFlag();
        this.mainDept = vo.getMainDept();
        this.roleName = vo.getRoleName();
    }

    @Override
    public SysUserVO convertToVO() {
        return new SysUserVO(this);
    }

    public enum ColName {
        user_id, username, password,name,phone,picture,state,flag
    }
}
